home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 2108 / 2108.xpi / content / manage-addons.js < prev    next >
Text File  |  2009-07-09  |  3KB  |  71 lines

  1. var stylishManageAddons = {
  2.  
  3.     init: function() {
  4.         //workaround for the overlay not working on mac
  5.         var view = document.getElementById("userstyles-view");
  6.         var viewParent = view.parentNode;
  7.         viewParent.removeChild(view);
  8.         viewParent.appendChild(view);
  9.         // this dialog can get all sorts of weird parameters that make it do stuff. let it do its thing if there are any.
  10.         if (document.getElementById("viewGroup").getAttribute("last-selected") == "userstyles-view" && (!"arguments" in window)) {
  11.             stylishManageAddons.changeCategoryToUserStyles();
  12.         }
  13.     },
  14.  
  15.     changeCategoryToUserStyles: function() {
  16.         stylishManageAddons.changeCategory({target:{id:"userstyles-view"}});
  17.     },
  18.  
  19.     needToResetExistingUI: false,
  20.  
  21.     changeCategory: function(event) {
  22.         // viewGroup is the strip, not any specific icon
  23.         if (event.target.id == "viewGroup")
  24.             return;
  25.         var on = event.target.id == "userstyles-view";
  26.         document.getElementById("styles-container").style.display = on ? "" : "none";
  27.         document.getElementById("addonsMsg").style.display = on ? "none" : "";
  28.         document.getElementById("new-style").style.display = on ? "-moz-box" : "none";
  29.         document.getElementById("copy-style-info").style.display = on ? "-moz-box" : "none";
  30.         var checkUpdates = document.getElementById("checkUpdatesAllButton");
  31.         if (on) {
  32.             document.getElementById("viewGroup").setAttribute("last-selected", "userstyles");
  33.  
  34.             function hide(id) {
  35.                 var e = document.getElementById(id);
  36.                 if (e) {
  37.                     e.hidden = true;
  38.                 }
  39.             }
  40.             ["installFileButton", "installUpdatesAllButton", "skipDialogButton", "continueDialogButton", "themePreviewArea", "themeSplitter", "showUpdateInfoButton", "hideUpdateInfoButton", "searchPanel", "getMore"].forEach(hide);
  41.             stylishManageAddons.needToResetExistingUI = true;
  42.             checkUpdates.setAttribute("commandoriginal", checkUpdates.getAttribute("command"));
  43.             checkUpdates.removeAttribute("command");
  44.             checkUpdates.setAttribute("oncommandoriginal", checkUpdates.getAttribute("oncommand"));
  45.             checkUpdates.setAttribute("oncommand", "stylishManage.updateAll()");
  46.             checkUpdates.hidden = false;
  47.             checkUpdates.disabled = false;
  48.         } else if (stylishManageAddons.needToResetExistingUI) {
  49.             checkUpdates.setAttribute("oncommand", checkUpdates.getAttribute("oncommandoriginal"));
  50.             checkUpdates.setAttribute("command", checkUpdates.getAttribute("commandoriginal"));
  51.             stylishManageAddons.needToResetExistingUI = false;
  52.         }
  53.     }
  54. }
  55.  
  56. window.addEventListener("load", function(){stylishManageAddons.init()}, false);
  57. document.getElementById("viewGroup").addEventListener("click", stylishManageAddons.changeCategory, false);
  58. window.addEventListener("DOMContentLoaded", function(event) {
  59.     showView2 = showView;
  60.     showView = function(view) {
  61.         if (view == "userstyles") {
  62.             document.getElementById("userstyles-view").click();
  63.         } else {
  64.             showView2(view);
  65.         }
  66.     };
  67. }, false);
  68.  
  69.  
  70.  
  71.